 <?php
	require("connection.php");
	header('Content-Type:text/html;charset=utf-8');
	session_start();
	if(isset($_POST['login'])){
	$userid = $_POST['userid'];
	$userpwd = $_POST['userpwd'];
	$sql = "select userid,userpwd from user where userid = '$userid' and userpwd = '$userpwd'";
	$queryresult = mysqli_query($connection,$sql);
	$row = mysqli_fetch_array($queryresult);
	if($userid == $row['userid'] && $userpwd == $row['userpwd']){
		$_SESSION['userid']=$userid;
		echo "<script language=\"JavaScript\">\r\n";
		echo " alert(\"登录成功 \");\r\n";
		echo "header('location:  first.html')";
		echo "</script>";
		header('location:  first.html'); 
		exit;
	}
	else {
		echo "<script language=\"JavaScript\">\r\n";
		echo " alert(\"输入错误 \");\r\n";
		echo " history.back();\r\n";
		echo "</script>";
		exit;
		}
	}
?>